package com.oracle.controller;

import com.oracle.pojo.Student;
import com.oracle.util.JJWTUtilsStudent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

public class BaseStudentController {
    @Autowired
    private HttpServletRequest request;

    public Student getUser(){
        //解析token
        String token = request.getHeader("Token");
        if (!StringUtils.isEmpty(token)){
            Student decode = JJWTUtilsStudent.decode(token);
            System.out.println(decode);
            return decode;
        }else {
            return null;
        }

    }

    public Student parseToken(String token){

        return JJWTUtilsStudent.decode(token);

    }
}
